package controllers;

import helpers.ConnectionHelper;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DemoServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		String url = "http://localhost:8888/demo";
		
		ConnectionHelper.postContent(url);
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		Enumeration headerNames = request.getHeaderNames();
		while (headerNames.hasMoreElements()) {
			String key = (String) headerNames.nextElement();
			String value = request.getHeader(key);
			if (key.toLowerCase().contains("gecko") || value.toLowerCase().contains("gecko")) {
				System.out.println("---------------------------");
				System.out.println("Key: " + key);
				System.out.println("Value: " + value);
			}
		}
		
	}
}
